package icu.mohan.erp.call.autoconfigure;

import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

import icu.mohan.erp.call.business.CallBusiness;
import icu.mohan.erp.call.business.ChildAccountBusiness;
import icu.mohan.erp.call.business.RecordBusiness;
import icu.mohan.erp.call.business.SeatBusiness;
import icu.mohan.erp.call.config.CallProperties;
import icu.mohan.erp.call.service.CallApiService;

/**
 * Starter 自动配置类
 *
 * @author yanglihao
 */
@Configuration
@EnableConfigurationProperties(CallProperties.class)
public class CallAutoConfiguration {

    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    @Bean
    public CallApiService callApiService(CallProperties callProperties) {
        return new CallApiService(callProperties, restTemplate());
    }

    @Bean
    public CallBusiness callBusiness(CallApiService callApiService) {
        return new CallBusiness(callApiService);
    }

    @Bean
    public ChildAccountBusiness childAccountBusiness(CallApiService callApiService) {
        return new ChildAccountBusiness(callApiService);
    }

    @Bean
    public RecordBusiness recordBusiness(CallApiService callApiService) {
        return new RecordBusiness(callApiService);
    }

    @Bean
    public SeatBusiness seatBusiness(CallApiService callApiService) {
        return new SeatBusiness(callApiService);
    }
}
